# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor: Mario Finelli <mario at finel do li>

_gemname='unf'
pkgname="ruby-${_gemname}"
pkgver=0.2.0.beta2
pkgrel=6
pkgdesc='Wrapper library to bring Unicode Normalization Form support to Ruby/JRuby.'
arch=('any')
url='https://github.com/knu/ruby-unf'
license=('BSD')
makedepends=('ruby-rdoc' 'ruby-bundler')
checkdepends=('ruby-rake')
depends=('ruby')
options=(!emptydirs)
source=("${url}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz")
sha512sums=('5fddb66913db6c143e68fea623be7c01636dff0d7ba74fd08b59f4e53672b3345fe518053ded1efb9fc9f44fef4097b607dadda796309fc91baa59d096493b82')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  # we build based on a tar ball, so `git` won't work here
  sed --in-place 's|git ls-files|find|' "${_gemname}.gemspec"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  rake test
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"

  rm -rf "${pkgdir}/${_gemdir}/cache"
}

# vim: ts=2 sw=2 et:
